<center>
<table class="expansion_overview" cellspacing="0px">
  <tr>
    <th>Logo</th>
    <th>Name</th>
    <th>Uniquely Owned cards</th>
    <th>Total cards</th>
    <th>Percentage</th>
  </tr>
<?php
  function getRowColor($number)
  {
    switch($number)
    {
      case(0):
        return "#FFF";
      case(1):
        return "#BBF";
      case(2):
        return "#BBB";
      case(3):
        return "#FBB";
      case(4):
        return "#BFB";
      default:
        return "#FFF";
    }
  }

  include_once dirname(__FILE__)."/../../database/database.class.php";

  $expansions = $db->getExpansions();
  $totalOwned = 0;
  $totalSize = 0;
  $rowColorID = 0;

  $expansion_rows = "";

  foreach($expansions as $expansion)
  {
    $amountOwned = (isset($_COOKIE["MGTDatabase_user"])) ? $db->getAmountOfUniqueCardsOwnedInExpansion($expansion->ID, $_COOKIE["MGTDatabase_user"]) : 0;
    $expansionsize = $db->getExpansionSize($expansion->internal_name);
    $percentage = ($expansionsize != 0) ? (floor($amountOwned/$expansionsize * 1000)/10)."%" : "N/A";

    $totalOwned+=$amountOwned;
    $totalSize+=$expansionsize;

    $expansion_rows .= '<tr style="background-color:'.getRowColor($rowColorID).'; border:1px solid black;">
            <td class="expansion_logo"><img src="./images/logo/'.$expansion->internal_name.'.png" width="20"></td>
            <td class="expansion_name"><a href="?expansionName='.$expansion->internal_name.'">'.$expansion->name.'</a></td>
            <td class="expansion_owned">'.$amountOwned.'</td>
            <td class="expansion_size">'.$expansionsize.'</td>
            <td class="expansion_percentage">'.$percentage.'</td>
          </tr>';
          
    $rowColorID = ($rowColorID+1)%5;
  }
  echo $expansion_rows."
  <tr>
    <th>Total:</th>
    <th></th>
    <th>".$totalOwned."</th>
    <th>".$totalSize."</th>
    <th>".floor($totalOwned/$totalSize * 100)."%</th>
  </tr>
  ";
?>
</table>
</center>
